package com.oocl.o2o.admin.entity;

import java.util.Arrays;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

/**
 * 0 通过 
 * 1 未通过
 *
 *
 */
@Entity
@GenericGenerator(strategy = "uuid", name = "aduuid")
public class Advertisement {
	@Id
	@GeneratedValue(generator = "aduuid")
	@Column(columnDefinition = "char(32)")
	private String id;
	@ManyToOne(targetEntity = Merchant.class,cascade=CascadeType.PERSIST)
	@JoinColumn(name = "merchant_id",columnDefinition = "char(32)",nullable=false)
	private Merchant merchant;
	private String foodName;
	private String foodId;
	private double foodPrice;
	@Lob
	private byte[] foodImage;
	private double tenderPrice;
	private String foodType;
	private String applyReason;
	private int approvalStatus;
	@Temporal(TemporalType.TIMESTAMP)
	private Date expiryDate;

	public Advertisement() {
		super();
	}

	

	public Advertisement(Merchant merchant, String foodName, String foodId,
			double foodPrice, byte[] foodImage, double tenderPrice,
			String foodType, String applyReason, int approvalStatus,
			Date expiryDate) {
		super();
		this.merchant = merchant;
		this.foodName = foodName;
		this.foodId = foodId;
		this.foodPrice = foodPrice;
		this.foodImage = foodImage;
		this.tenderPrice = tenderPrice;
		this.foodType = foodType;
		this.applyReason = applyReason;
		this.approvalStatus = approvalStatus;
		this.expiryDate = expiryDate;
	}



	

	public Advertisement(String id, Merchant merchant, String foodName,
			String foodId, double foodPrice, byte[] foodImage,
			double tenderPrice, String foodType, String applyReason,
			int approvalStatus, Date expiryDate) {
		super();
		this.id = id;
		this.merchant = merchant;
		this.foodName = foodName;
		this.foodId = foodId;
		this.foodPrice = foodPrice;
		this.foodImage = foodImage;
		this.tenderPrice = tenderPrice;
		this.foodType = foodType;
		this.applyReason = applyReason;
		this.approvalStatus = approvalStatus;
		this.expiryDate = expiryDate;
	}



	public String getApplyReason() {
		return applyReason;
	}



	public void setApplyReason(String applyReason) {
		this.applyReason = applyReason;
	}



	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public String getFoodName() {
		return foodName;
	}

	public void setFoodName(String foodName) {
		this.foodName = foodName;
	}

	public String getFoodId() {
		return foodId;
	}

	public void setFoodId(String foodId) {
		this.foodId = foodId;
	}

	public double getFoodPrice() {
		return foodPrice;
	}

	public void setFoodPrice(double foodPrice) {
		this.foodPrice = foodPrice;
	}

	public byte[] getFoodImage() {
		return foodImage;
	}

	public void setFoodImage(byte[] foodImage) {
		this.foodImage = foodImage;
	}

	public double getTenderPrice() {
		return tenderPrice;
	}

	public void setTenderPrice(double tenderPrice) {
		this.tenderPrice = tenderPrice;
	}

	public String getFoodType() {
		return foodType;
	}

	public void setFoodType(String foodType) {
		this.foodType = foodType;
	}

	public int getApprovalStatus() {
		return approvalStatus;
	}

	public void setApprovalStatus(int approvalStatus) {
		this.approvalStatus = approvalStatus;
	}

	public Date getExpiryDate() {
		return expiryDate;
	}

	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((foodId == null) ? 0 : foodId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Advertisement other = (Advertisement) obj;
		if (foodId == null) {
			if (other.foodId != null)
				return false;
		} else if (!foodId.equals(other.foodId))
			return false;
		return true;
	}



	@Override
	public String toString() {
		return "Advertisement [id=" + id + ",foodName=" + foodName + ", foodId=" + foodId
				+ ", foodPrice=" + foodPrice + ", foodImage="
				+ Arrays.toString(foodImage) + ", tenderPrice=" + tenderPrice
				+ ", foodType=" + foodType + ", applyReason=" + applyReason
				+ ", approvalStatus=" + approvalStatus + ", expiryDate="
				+ expiryDate + "]";
	}

	

}
